//
//  BaseTableViewCell.m
//  PhotographyStudi
//
//  Created by 叶一枫 on 2017/5/10.
//  Copyright © 2017年 叶一枫. All rights reserved.
//


//=========================================//
//要求cell 最小高度 40
//=========================================//


#import "BaseTableViewCell.h"

@implementation BaseTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier UIType:(CELLENUM)UIType{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.UIType = UIType;
    }
    return self;
}


-(void)layoutSubviews{

    [super layoutSubviews];
    CGFloat cellW = self.contentView.frame.size.width;
    CGFloat cellH = self.contentView.frame.size.height;
    
    self.containView.frame = self.bounds;
    
    switch (self.UIType) {
        case BASECELL:
            self.itemImageView.frame = CGRectMake(5, (cellH - 20)/2, 20, 20);
            self.itemLabel.frame = CGRectMake(30, 5, cellW - 80, cellH - 10);
            break;
        case DETAILCELL:
            self.itemImageView.frame = CGRectMake(5, (cellH - 20)/2, 20, 20);
            self.itemLabel.frame = CGRectMake(30, (cellH - 40)/3, cellW - 80, 20);
            self.detailLaebl.frame = CGRectMake(30, CGRectGetMaxY(self.itemLabel.frame)+(cellH - 40)/3, cellW - 80, 20);
            break;
        case DETAILTIMECELL:
            self.itemImageView.frame = CGRectMake(5, (cellH - 20)/2, 20, 20);
            self.itemLabel.frame = CGRectMake(30, (cellH - 40)/3, cellW - 80, 20);
            self.detailLaebl.frame = CGRectMake(30, CGRectGetMaxY(self.itemLabel.frame)+(cellH - 40)/3, [[BSTool sharedBSTool] getSizeWithStr:self.detailLaebl.text size:20 font:self.detailLaebl.font height:NO].width, 20);
            
            self.timeLaebl.frame = CGRectMake(CGRectGetMaxX(self.detailLaebl.frame) + 15, CGRectGetMaxY(self.itemLabel.frame)+(cellH - 40)/3, cellW - 80, 20);
            
            break;
            
        case BASECELLSINGLE:
            self.itemLabel.frame = CGRectMake(20, 5, cellW - 40, cellH - 10);
            break;
        case DETAILCELLSINGLE:
            self.itemLabel.frame = CGRectMake(20, (cellH - 40)/3, cellW - 80, 20);
            self.detailLaebl.frame = CGRectMake(20, CGRectGetMaxY(self.itemLabel.frame)+(cellH - 40)/3, cellW - 80, 20);
            break;
        case DETAILTIMECELLSINGLE:
            self.itemLabel.frame = CGRectMake(20, (cellH - 40)/3, cellW - 80, 20);
            self.detailLaebl.frame = CGRectMake(20, CGRectGetMaxY(self.itemLabel.frame)+(cellH - 40)/3, [[BSTool sharedBSTool] getSizeWithStr:self.detailLaebl.text size:20 font:self.detailLaebl.font height:NO].width, 20);
            
            self.timeLaebl.frame = CGRectMake(CGRectGetMaxX(self.detailLaebl.frame) + 15, CGRectGetMaxY(self.itemLabel.frame)+(cellH - 40)/3, cellW - 80, 20);
            break;
        default:
            break;
    }
}

//- (void)drawRect:(CGRect)rect {
//    CGContextRef context = UIGraphicsGetCurrentContext();
//    CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
//    CGContextFillRect(context, rect);
//    //上分割线，
//    //CGContextSetStrokeColorWithColor(context, COLORWHITE.CGColor);
//    //CGContextStrokeRect(context, CGRectMake(5, -1, rect.size.width - 10, 1));
//    //下分割线
//    CGContextSetStrokeColorWithColor(context,[UIColor groupTableViewBackgroundColor].CGColor);
//    CGContextStrokeRect(context,CGRectMake(0, rect.size.height-0.5, rect.size.width,1));
//    
//}

-(void)loadModelArr:(NSDictionary *)modelArr type:(NSString *)type{


}


-(void)loadModelDic:(NSDictionary *)modelDic type:(NSString *)type{


}

-(void)updateUI{

   
}


-(UILabel *)itemLabel{

    if (!_itemLabel) {
        _itemLabel = [[UILabel alloc]init];
        [self.contentView addSubview:_itemLabel];
    }
    return _itemLabel;
}

-(UIImageView *)itemImageView{
    if (!_itemImageView) {
        _itemImageView = [[UIImageView alloc]init];
        [self addSubview:_itemImageView];
    }
    return _itemImageView;
}

-(UILabel *)detailLaebl{
    if (!_detailLaebl) {
        _detailLaebl = [[UILabel alloc]init];
        [self addSubview:_detailLaebl];
    }
    return _detailLaebl;
}

-(UILabel *)timeLaebl{
    if (!_timeLaebl) {
        _timeLaebl = [[UILabel alloc]init];
        [self addSubview:_timeLaebl];
    }
    return _timeLaebl;
}

-(UIView *)containView{
    if (!_containView) {
        _containView = [[UILabel alloc]init];
        [self.contentView addSubview:_containView];
    }
    return _containView;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
